;(function($){
    $(function(){
        $("#main").find("li").on("click", function(){
            $index = $(this).index();
            //console.log($index);
            $(".box").eq($index).show().siblings(".box").hide()
        })

        $("#btn2").on("click", function(){
            window.location = "register1.html"
        })

        $("form").validate({
            messages : {
                uname:"用户名必填哦",
                upwd:"密码必填哦"
            },
            rules : {
                uname:"required",
                upwd:"required"
            },
            submitHandler:function(){
                //console.log($("form").serialize());
                $.ajax({
                    //http://127.0.0.1/yemaijiu/yemaijiu/index/login.html
                    url:"./server/loginserver.php",
                    dataType:"json",
                    type:"post",
                    data:$("form").serialize()
                 }).then(function (res) {
                    if (res.status==1) {
                        if(confirm("登录成功")){
                            layer.alert('登录成功')
                            window.location="indexx.html"
                        }

                       localStorage.setItem("userinfo1",JSON.stringify(res.data));

                       // PHPSESSID=6n25t9h04rtvo41kdropr7mt51
                    }else {
                        layer.alert('登录失败', {
                            icon: 5,
                            skin: 'layer-ext-moon' //该皮肤由layer.seaning.com友情扩展。关于皮肤的扩展规则，去这里查阅
                        })
                    }
                });
            }
        });
        $("#btn2").on("click",function(){
            window.location="register1.html"
        })
    })
})(jQuery);